package com.java;

/**
 * lambda Express
 * 口诀: 拷贝小括号，写死右箭头，落地大括号
 * @FunctionalInterface
 * default默认方法
 * static 静态方法
 * @author jingjintao
 * @date 2021/10/23 - 20:54
 **/

public class LambdaExpressDemo {

    public static void main(String[] args) {
        /*Foo foo = new Foo() {
            @Override
            public void sayHello() {
                System.out.println("****Hello");
            }
        };
        foo.sayHello();*/
        /*Foo foo = () -> {
            System.out.println("****Hello lambda express");
        };
        foo.sayHello();*/

        Foo foo = (x, y) -> {
            System.out.println("come in ...");
            return x + y;
        };
        System.out.println(foo.div(10, 5));
        System.out.println(foo.multi(2, 3));

        System.out.println(Foo.add(3, 6));
    }
}

@FunctionalInterface
interface Foo{
//    public void sayHello();
    public int div(int x, int y);

    default int multi(int x, int y){
        System.out.println("mulit....");
        return x * y;
    }

    public static int add(int x, int y){
        System.out.println("add...");
        return x + y;
    }

}
